#ifndef THINK_THINK_LOADER_H
#define THINK_THINK_LOADER_H

static char* think_loader =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: liu21st <liu21st@gmail.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think;\n"
	"\n"
	"use think\\exception\\ClassNotFoundException;\n"
	"\n"
	"class Loader\n"
	"{\n"
	"    /**\n"
	"     * @var array 实例数组\n"
	"     */\n"
	"    protected static $instance = [];\n"
	"\n"
	"    /**\n"
	"     * @var array 类名映射\n"
	"     */\n"
	"    protected static $classMap = [];\n"
	"\n"
	"    /**\n"
	"     * @var array 命名空间别名\n"
	"     */\n"
	"    protected static $namespaceAlias = [];\n"
	"\n"
	"    /**\n"
	"     * @var array PSR-4 命名空间前缀长度映射\n"
	"     */\n"
	"    private static $prefixLengthsPsr4 = [];\n"
	"\n"
	"    /**\n"
	"     * @var array PSR-4 的加载目录\n"
	"     */\n"
	"    private static $prefixDirsPsr4 = [];\n"
	"\n"
	"    /**\n"
	"     * @var array PSR-4 加载失败的回退目录\n"
	"     */\n"
	"    private static $fallbackDirsPsr4 = [];\n"
	"\n"
	"    /**\n"
	"     * @var array PSR-0 命名空间前缀映射\n"
	"     */\n"
	"    private static $prefixesPsr0 = [];\n"
	"\n"
	"    /**\n"
	"     * @var array PSR-0 加载失败的回退目录\n"
	"     */\n"
	"    private static $fallbackDirsPsr0 = [];\n"
	"\n"
	"    /**\n"
	"     * @var array 需要加载的文件\n"
	"     */\n"
	"    private static $files = [];\n"
	"\n"
	"    /**\n"
	"     * 自动加载\n"
	"     * @access public\n"
	"     * @param  string $class 类名\n"
	"     * @return bool\n"
	"     */\n"
	"    public static function autoload($class)\n"
	"    {\n"
	"        // 检测命名空间别名\n"
	"        if (!empty(self::$namespaceAlias)) {\n"
	"            $namespace = dirname($class);\n"
	"            if (isset(self::$namespaceAlias[$namespace])) {\n"
	"                $original = self::$namespaceAlias[$namespace] . \'\\\\\' . basename($class);\n"
	"                if (class_exists($original)) {\n"
	"                    return class_alias($original, $class, false);\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if ($file = self::findFile($class)) {\n"
	"            // 非 Win 环境不严格区分大小写\n"
	"            if (!IS_WIN || pathinfo($file, PATHINFO_FILENAME) == pathinfo(realpath($file), PATHINFO_FILENAME)) {\n"
	"                __include_file($file);\n"
	"                return true;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return false;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 查找文件\n"
	"     * @access private\n"
	"     * @param  string $class 类名\n"
	"     * @return bool|string\n"
	"     */\n"
	"    private static function findFile($class)\n"
	"    {\n"
	"        // 类库映射\n"
	"        if (!empty(self::$classMap[$class])) {\n"
	"            return self::$classMap[$class];\n"
	"        }\n"
	"\n"
	"        // 查找 PSR-4\n"
	"        $logicalPathPsr4 = strtr($class, \'\\\\\', DS) . EXT;\n"
	"        $first           = $class[0];\n"
	"\n"
	"        if (isset(self::$prefixLengthsPsr4[$first])) {\n"
	"            foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) {\n"
	"                if (0 === strpos($class, $prefix)) {\n"
	"                    foreach (self::$prefixDirsPsr4[$prefix] as $dir) {\n"
	"                        if (is_file($file = $dir . DS . substr($logicalPathPsr4, $length))) {\n"
	"                            return $file;\n"
	"                        }\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 查找 PSR-4 fallback dirs\n"
	"        foreach (self::$fallbackDirsPsr4 as $dir) {\n"
	"            if (is_file($file = $dir . DS . $logicalPathPsr4)) {\n"
	"                return $file;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 查找 PSR-0\n"
	"        if (false !== $pos = strrpos($class, \'\\\\\')) {\n"
	"            // namespace class name\n"
	"            $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)\n"
	"            . strtr(substr($logicalPathPsr4, $pos + 1), \'_\', DS);\n"
	"        } else {\n"
	"            // PEAR-like class name\n"
	"            $logicalPathPsr0 = strtr($class, \'_\', DS) . EXT;\n"
	"        }\n"
	"\n"
	"        if (isset(self::$prefixesPsr0[$first])) {\n"
	"            foreach (self::$prefixesPsr0[$first] as $prefix => $dirs) {\n"
	"                if (0 === strpos($class, $prefix)) {\n"
	"                    foreach ($dirs as $dir) {\n"
	"                        if (is_file($file = $dir . DS . $logicalPathPsr0)) {\n"
	"                            return $file;\n"
	"                        }\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 查找 PSR-0 fallback dirs\n"
	"        foreach (self::$fallbackDirsPsr0 as $dir) {\n"
	"            if (is_file($file = $dir . DS . $logicalPathPsr0)) {\n"
	"                return $file;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 找不到则设置映射为 false 并返回\n"
	"        return self::$classMap[$class] = false;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 注册 classmap\n"
	"     * @access public\n"
	"     * @param  string|array $class 类名\n"
	"     * @param  string       $map   映射\n"
	"     * @return void\n"
	"     */\n"
	"    public static function addClassMap($class, $map = \'\')\n"
	"    {\n"
	"        if (is_array($class)) {\n"
	"            self::$classMap = array_merge(self::$classMap, $class);\n"
	"        } else {\n"
	"            self::$classMap[$class] = $map;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 注册命名空间\n"
	"     * @access public\n"
	"     * @param  string|array $namespace 命名空间\n"
	"     * @param  string       $path      路径\n"
	"     * @return void\n"
	"     */\n"
	"    public static function addNamespace($namespace, $path = \'\')\n"
	"    {\n"
	"        if (is_array($namespace)) {\n"
	"            foreach ($namespace as $prefix => $paths) {\n"
	"                self::addPsr4($prefix . \'\\\\\', rtrim($paths, DS), true);\n"
	"            }\n"
	"        } else {\n"
	"            self::addPsr4($namespace . \'\\\\\', rtrim($path, DS), true);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 添加 PSR-0 命名空间\n"
	"     * @access private\n"
	"     * @param  array|string $prefix  空间前缀\n"
	"     * @param  array        $paths   路径\n"
	"     * @param  bool         $prepend 预先设置的优先级更高\n"
	"     * @return void\n"
	"     */\n"
	"    private static function addPsr0($prefix, $paths, $prepend = false)\n"
	"    {\n"
	"        if (!$prefix) {\n"
	"            self::$fallbackDirsPsr0 = $prepend ?\n"
	"            array_merge((array) $paths, self::$fallbackDirsPsr0) :\n"
	"            array_merge(self::$fallbackDirsPsr0, (array) $paths);\n"
	"        } else {\n"
	"            $first = $prefix[0];\n"
	"\n"
	"            if (!isset(self::$prefixesPsr0[$first][$prefix])) {\n"
	"                self::$prefixesPsr0[$first][$prefix] = (array) $paths;\n"
	"            } else {\n"
	"                self::$prefixesPsr0[$first][$prefix] = $prepend ?\n"
	"                array_merge((array) $paths, self::$prefixesPsr0[$first][$prefix]) :\n"
	"                array_merge(self::$prefixesPsr0[$first][$prefix], (array) $paths);\n"
	"            }\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 添加 PSR-4 空间\n"
	"     * @access private\n"
	"     * @param  array|string $prefix  空间前缀\n"
	"     * @param  string       $paths   路径\n"
	"     * @param  bool         $prepend 预先设置的优先级更高\n"
	"     * @return void\n"
	"     */\n"
	"    private static function addPsr4($prefix, $paths, $prepend = false)\n"
	"    {\n"
	"        if (!$prefix) {\n"
	"            // Register directories for the root namespace.\n"
	"            self::$fallbackDirsPsr4 = $prepend ?\n"
	"            array_merge((array) $paths, self::$fallbackDirsPsr4) :\n"
	"            array_merge(self::$fallbackDirsPsr4, (array) $paths);\n"
	"\n"
	"        } elseif (!isset(self::$prefixDirsPsr4[$prefix])) {\n"
	"            // Register directories for a new namespace.\n"
	"            $length = strlen($prefix);\n"
	"            if (\'\\\\\' !== $prefix[$length - 1]) {\n"
	"                throw new \\InvalidArgumentException(\n"
	"                    \"A non-empty PSR-4 prefix must end with a namespace separator.\"\n"
	"                );\n"
	"            }\n"
	"\n"
	"            self::$prefixLengthsPsr4[$prefix[0]][$prefix] = $length;\n"
	"            self::$prefixDirsPsr4[$prefix]                = (array) $paths;\n"
	"\n"
	"        } else {\n"
	"            self::$prefixDirsPsr4[$prefix] = $prepend ?\n"
	"            // Prepend directories for an already registered namespace.\n"
	"            array_merge((array) $paths, self::$prefixDirsPsr4[$prefix]) :\n"
	"            // Append directories for an already registered namespace.\n"
	"            array_merge(self::$prefixDirsPsr4[$prefix], (array) $paths);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 注册命名空间别名\n"
	"     * @access public\n"
	"     * @param  array|string $namespace 命名空间\n"
	"     * @param  string       $original  源文件\n"
	"     * @return void\n"
	"     */\n"
	"    public static function addNamespaceAlias($namespace, $original = \'\')\n"
	"    {\n"
	"        if (is_array($namespace)) {\n"
	"            self::$namespaceAlias = array_merge(self::$namespaceAlias, $namespace);\n"
	"        } else {\n"
	"            self::$namespaceAlias[$namespace] = $original;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 注册自动加载机制\n"
	"     * @access public\n"
	"     * @param  callable $autoload 自动加载处理方法\n"
	"     * @return void\n"
	"     */\n"
	"    public static function register($autoload = null)\n"
	"    {\n"
	"        // 注册系统自动加载\n"
	"        spl_autoload_register($autoload ?: \'think\\\\Loader::autoload\', true, true);\n"
	"\n"
	"        // Composer 自动加载支持\n"
	"        if (is_dir(VENDOR_PATH . \'composer\')) {\n"
	"            if (PHP_VERSION_ID >= 50600 && is_file(VENDOR_PATH . \'composer\' . DS . \'autoload_static.php\')) {\n"
	"                require VENDOR_PATH . \'composer\' . DS . \'autoload_static.php\';\n"
	"\n"
	"                $declaredClass = get_declared_classes();\n"
	"                $composerClass = array_pop($declaredClass);\n"
	"\n"
	"                foreach ([\'prefixLengthsPsr4\', \'prefixDirsPsr4\', \'fallbackDirsPsr4\', \'prefixesPsr0\', \'fallbackDirsPsr0\', \'classMap\', \'files\'] as $attr) {\n"
	"                    if (property_exists($composerClass, $attr)) {\n"
	"                        self::${$attr} = $composerClass::${$attr};\n"
	"                    }\n"
	"                }\n"
	"            } else {\n"
	"                self::registerComposerLoader();\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 注册命名空间定义\n"
	"        self::addNamespace([\n"
	"            \'think\'    => LIB_PATH . \'think\' . DS,\n"
	"            \'behavior\' => LIB_PATH . \'behavior\' . DS,\n"
	"            \'traits\'   => LIB_PATH . \'traits\' . DS,\n"
	"        ]);\n"
	"\n"
	"        // 加载类库映射文件\n"
	"        if (is_file(RUNTIME_PATH . \'classmap\' . EXT)) {\n"
	"            self::addClassMap(__include_file(RUNTIME_PATH . \'classmap\' . EXT));\n"
	"        }\n"
	"\n"
	"        self::loadComposerAutoloadFiles();\n"
	"\n"
	"        // 自动加载 extend 目录\n"
	"        self::$fallbackDirsPsr4[] = rtrim(EXTEND_PATH, DS);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 注册 composer 自动加载\n"
	"     * @access private\n"
	"     * @return void\n"
	"     */\n"
	"    private static function registerComposerLoader()\n"
	"    {\n"
	"        if (is_file(VENDOR_PATH . \'composer/autoload_namespaces.php\')) {\n"
	"            $map = require VENDOR_PATH . \'composer/autoload_namespaces.php\';\n"
	"            foreach ($map as $namespace => $path) {\n"
	"                self::addPsr0($namespace, $path);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if (is_file(VENDOR_PATH . \'composer/autoload_psr4.php\')) {\n"
	"            $map = require VENDOR_PATH . \'composer/autoload_psr4.php\';\n"
	"            foreach ($map as $namespace => $path) {\n"
	"                self::addPsr4($namespace, $path);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if (is_file(VENDOR_PATH . \'composer/autoload_classmap.php\')) {\n"
	"            $classMap = require VENDOR_PATH . \'composer/autoload_classmap.php\';\n"
	"            if ($classMap) {\n"
	"                self::addClassMap($classMap);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        if (is_file(VENDOR_PATH . \'composer/autoload_files.php\')) {\n"
	"            self::$files = require VENDOR_PATH . \'composer/autoload_files.php\';\n"
	"        }\n"
	"    }\n"
	"\n"
	"    // 加载composer autofile文件\n"
	"    public static function loadComposerAutoloadFiles()\n"
	"    {\n"
	"        foreach (self::$files as $fileIdentifier => $file) {\n"
	"            if (empty($GLOBALS[\'__composer_autoload_files\'][$fileIdentifier])) {\n"
	"                __require_file($file);\n"
	"\n"
	"                $GLOBALS[\'__composer_autoload_files\'][$fileIdentifier] = true;\n"
	"            }\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 导入所需的类库 同 Java 的 Import 本函数有缓存功能\n"
	"     * @access public\n"
	"     * @param  string $class   类库命名空间字符串\n"
	"     * @param  string $baseUrl 起始路径\n"
	"     * @param  string $ext     导入的文件扩展名\n"
	"     * @return bool\n"
	"     */\n"
	"    public static function import($class, $baseUrl = \'\', $ext = EXT)\n"
	"    {\n"
	"        static $_file = [];\n"
	"        $key          = $class . $baseUrl;\n"
	"        $class        = str_replace([\'.\', \'#\'], [DS, \'.\'], $class);\n"
	"\n"
	"        if (isset($_file[$key])) {\n"
	"            return true;\n"
	"        }\n"
	"\n"
	"        if (empty($baseUrl)) {\n"
	"            list($name, $class) = explode(DS, $class, 2);\n"
	"\n"
	"            if (isset(self::$prefixDirsPsr4[$name . \'\\\\\'])) {\n"
	"                // 注册的命名空间\n"
	"                $baseUrl = self::$prefixDirsPsr4[$name . \'\\\\\'];\n"
	"            } elseif (\'@\' == $name) {\n"
	"                // 加载当前模块应用类库\n"
	"                $baseUrl = App::$modulePath;\n"
	"            } elseif (is_dir(EXTEND_PATH . $name)) {\n"
	"                $baseUrl = EXTEND_PATH . $name . DS;\n"
	"            } else {\n"
	"                // 加载其它模块的类库\n"
	"                $baseUrl = APP_PATH . $name . DS;\n"
	"            }\n"
	"        } elseif (substr($baseUrl, -1) != DS) {\n"
	"            $baseUrl .= DS;\n"
	"        }\n"
	"\n"
	"        // 如果类存在则导入类库文件\n"
	"        if (is_array($baseUrl)) {\n"
	"            foreach ($baseUrl as $path) {\n"
	"                if (is_file($filename = $path . DS . $class . $ext)) {\n"
	"                    break;\n"
	"                }\n"
	"            }\n"
	"        } else {\n"
	"            $filename = $baseUrl . $class . $ext;\n"
	"        }\n"
	"\n"
	"        if (!empty($filename) &&\n"
	"            is_file($filename) &&\n"
	"            (!IS_WIN || pathinfo($filename, PATHINFO_FILENAME) == pathinfo(realpath($filename), PATHINFO_FILENAME))\n"
	"        ) {\n"
	"            __include_file($filename);\n"
	"            $_file[$key] = true;\n"
	"\n"
	"            return true;\n"
	"        }\n"
	"\n"
	"        return false;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 实例化（分层）模型\n"
	"     * @access public\n"
	"     * @param  string $name         Model名称\n"
	"     * @param  string $layer        业务层名称\n"
	"     * @param  bool   $appendSuffix 是否添加类名后缀\n"
	"     * @param  string $common       公共模块名\n"
	"     * @return object\n"
	"     * @throws ClassNotFoundException\n"
	"     */\n"
	"    public static function model($name = \'\', $layer = \'model\', $appendSuffix = false, $common = \'common\')\n"
	"    {\n"
	"        $uid = $name . $layer;\n"
	"\n"
	"        if (isset(self::$instance[$uid])) {\n"
	"            return self::$instance[$uid];\n"
	"        }\n"
	"\n"
	"        list($module, $class) = self::getModuleAndClass($name, $layer, $appendSuffix);\n"
	"\n"
	"        if (class_exists($class)) {\n"
	"            $model = new $class();\n"
	"        } else {\n"
	"            $class = str_replace(\'\\\\\' . $module . \'\\\\\', \'\\\\\' . $common . \'\\\\\', $class);\n"
	"\n"
	"            if (class_exists($class)) {\n"
	"                $model = new $class();\n"
	"            } else {\n"
	"                throw new ClassNotFoundException(\'class not exists:\' . $class, $class);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return self::$instance[$uid] = $model;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 实例化（分层）控制器 格式：[模块名/]控制器名\n"
	"     * @access public\n"
	"     * @param  string $name         资源地址\n"
	"     * @param  string $layer        控制层名称\n"
	"     * @param  bool   $appendSuffix 是否添加类名后缀\n"
	"     * @param  string $empty        空控制器名称\n"
	"     * @return object\n"
	"     * @throws ClassNotFoundException\n"
	"     */\n"
	"    public static function controller($name, $layer = \'controller\', $appendSuffix = false, $empty = \'\')\n"
	"    {\n"
	"        list($module, $class) = self::getModuleAndClass($name, $layer, $appendSuffix);\n"
	"\n"
	"        if (class_exists($class)) {\n"
	"            return App::invokeClass($class);\n"
	"        }\n"
	"\n"
	"        if ($empty) {\n"
	"            $emptyClass = self::parseClass($module, $layer, $empty, $appendSuffix);\n"
	"\n"
	"            if (class_exists($emptyClass)) {\n"
	"                return new $emptyClass(Request::instance());\n"
	"            }\n"
	"        }\n"
	"\n"
	"        throw new ClassNotFoundException(\'class not exists:\' . $class, $class);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 实例化验证类 格式：[模块名/]验证器名\n"
	"     * @access public\n"
	"     * @param  string $name         资源地址\n"
	"     * @param  string $layer        验证层名称\n"
	"     * @param  bool   $appendSuffix 是否添加类名后缀\n"
	"     * @param  string $common       公共模块名\n"
	"     * @return object|false\n"
	"     * @throws ClassNotFoundException\n"
	"     */\n"
	"    public static function validate($name = \'\', $layer = \'validate\', $appendSuffix = false, $common = \'common\')\n"
	"    {\n"
	"        $name = $name ?: Config::get(\'default_validate\');\n"
	"\n"
	"        if (empty($name)) {\n"
	"            return new Validate;\n"
	"        }\n"
	"\n"
	"        $uid = $name . $layer;\n"
	"        if (isset(self::$instance[$uid])) {\n"
	"            return self::$instance[$uid];\n"
	"        }\n"
	"\n"
	"        list($module, $class) = self::getModuleAndClass($name, $layer, $appendSuffix);\n"
	"\n"
	"        if (class_exists($class)) {\n"
	"            $validate = new $class;\n"
	"        } else {\n"
	"            $class = str_replace(\'\\\\\' . $module . \'\\\\\', \'\\\\\' . $common . \'\\\\\', $class);\n"
	"\n"
	"            if (class_exists($class)) {\n"
	"                $validate = new $class;\n"
	"            } else {\n"
	"                throw new ClassNotFoundException(\'class not exists:\' . $class, $class);\n"
	"            }\n"
	"        }\n"
	"\n"
	"        return self::$instance[$uid] = $validate;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 解析模块和类名\n"
	"     * @access protected\n"
	"     * @param  string $name         资源地址\n"
	"     * @param  string $layer        验证层名称\n"
	"     * @param  bool   $appendSuffix 是否添加类名后缀\n"
	"     * @return array\n"
	"     */\n"
	"    protected static function getModuleAndClass($name, $layer, $appendSuffix)\n"
	"    {\n"
	"        if (false !== strpos($name, \'\\\\\')) {\n"
	"            $module = Request::instance()->module();\n"
	"            $class  = $name;\n"
	"        } else {\n"
	"            if (strpos($name, \'/\')) {\n"
	"                list($module, $name) = explode(\'/\', $name, 2);\n"
	"            } else {\n"
	"                $module = Request::instance()->module();\n"
	"            }\n"
	"\n"
	"            $class = self::parseClass($module, $layer, $name, $appendSuffix);\n"
	"        }\n"
	"\n"
	"        return [$module, $class];\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 数据库初始化 并取得数据库类实例\n"
	"     * @access public\n"
	"     * @param  mixed       $config 数据库配置\n"
	"     * @param  bool|string $name   连接标识 true 强制重新连接\n"
	"     * @return \\think\\db\\Connection\n"
	"     */\n"
	"    public static function db($config = [], $name = false)\n"
	"    {\n"
	"        return Db::connect($config, $name);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 远程调用模块的操作方法 参数格式 [模块/控制器/]操作\n"
	"     * @access public\n"
	"     * @param  string       $url          调用地址\n"
	"     * @param  string|array $vars         调用参数 支持字符串和数组\n"
	"     * @param  string       $layer        要调用的控制层名称\n"
	"     * @param  bool         $appendSuffix 是否添加类名后缀\n"
	"     * @return mixed\n"
	"     */\n"
	"    public static function action($url, $vars = [], $layer = \'controller\', $appendSuffix = false)\n"
	"    {\n"
	"        $info   = pathinfo($url);\n"
	"        $action = $info[\'basename\'];\n"
	"        $module = \'.\' != $info[\'dirname\'] ? $info[\'dirname\'] : Request::instance()->controller();\n"
	"        $class  = self::controller($module, $layer, $appendSuffix);\n"
	"\n"
	"        if ($class) {\n"
	"            if (is_scalar($vars)) {\n"
	"                if (strpos($vars, \'=\')) {\n"
	"                    parse_str($vars, $vars);\n"
	"                } else {\n"
	"                    $vars = [$vars];\n"
	"                }\n"
	"            }\n"
	"\n"
	"            return App::invokeMethod([$class, $action . Config::get(\'action_suffix\')], $vars);\n"
	"        }\n"
	"\n"
	"        return false;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 字符串命名风格转换\n"
	"     * type 0 将 Java 风格转换为 C 的风格 1 将 C 风格转换为 Java 的风格\n"
	"     * @access public\n"
	"     * @param  string  $name    字符串\n"
	"     * @param  integer $type    转换类型\n"
	"     * @param  bool    $ucfirst 首字母是否大写（驼峰规则）\n"
	"     * @return string\n"
	"     */\n"
	"    public static function parseName($name, $type = 0, $ucfirst = true)\n"
	"    {\n"
	"        if ($type) {\n"
	"            $name = preg_replace_callback(\'/_([a-zA-Z])/\', function ($match) {\n"
	"                return strtoupper($match[1]);\n"
	"            }, $name);\n"
	"\n"
	"            return $ucfirst ? ucfirst($name) : lcfirst($name);\n"
	"        }\n"
	"\n"
	"        return strtolower(trim(preg_replace(\"/[A-Z]/\", \"_\\\\0\", $name), \"_\"));\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 解析应用类的类名\n"
	"     * @access public\n"
	"     * @param  string $module       模块名\n"
	"     * @param  string $layer        层名 controller model ...\n"
	"     * @param  string $name         类名\n"
	"     * @param  bool   $appendSuffix 是否添加类名后缀\n"
	"     * @return string\n"
	"     */\n"
	"    public static function parseClass($module, $layer, $name, $appendSuffix = false)\n"
	"    {\n"
	"\n"
	"        $array = explode(\'\\\\\', str_replace([\'/\', \'.\'], \'\\\\\', $name));\n"
	"        $class = self::parseName(array_pop($array), 1);\n"
	"        $class = $class . (App::$suffix || $appendSuffix ? ucfirst($layer) : \'\');\n"
	"        $path  = $array ? implode(\'\\\\\', $array) . \'\\\\\' : \'\';\n"
	"\n"
	"        return App::$namespace . \'\\\\\' .\n"
	"            ($module ? $module . \'\\\\\' : \'\') .\n"
	"            $layer . \'\\\\\' . $path . $class;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 初始化类的实例\n"
	"     * @access public\n"
	"     * @return void\n"
	"     */\n"
	"    public static function clearInstance()\n"
	"    {\n"
	"        self::$instance = [];\n"
	"    }\n"
	"}\n"
	"\n"
	"// 作用范围隔离\n"
	"\n"
	"/**\n"
	" * include\n"
	" * @param  string $file 文件路径\n"
	" * @return mixed\n"
	" */\n"
	"function __include_file($file)\n"
	"{\n"
	"    return include $file;\n"
	"}\n"
	"\n"
	"/**\n"
	" * require\n"
	" * @param  string $file 文件路径\n"
	" * @return mixed\n"
	" */\n"
	"function __require_file($file)\n"
	"{\n"
	"    return require $file;\n"
	"}\n"
	"\n"
;
#endif